<template>
    <h1>登录页</h1>
    用户名:<input type="text" v-model="username"/><br />
    密码:<input type="text" v-model="password"/><br />
    <button @click="login">登录</button>
</template>

<script setup>
    
    // 组合式编程
    import { ref } from "vue"

    // 导入路由组件 
    import {useRouter,useRoute} from 'vue-router'
    const router = useRouter()
    const route = useRoute()
    
    var username = ref("");
    var password = ref("");

    // 定义方法
    function login()
    {
        console.log(username.value)
        console.log(password.value)

        if(username.value=="admin" && password.value=="123456")
        {
            alert("登录成功")
            router.replace("/home")
        }
        else
        {
            alert("登录失败")
        }
    }

</script>